MX-17245 · Improve shard processor coverage#7350
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/supernova-async-exec #7350 +/- ##
=============================================================
+ Coverage 75.68% 75.69% +0.01%
=============================================================
Files 860 860
Lines 141702 141698 -4
=============================================================
+ Hits 107248 107264 +16
+ Misses 28514 28500 -14
+ Partials 5940 5934 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| return sp.collectExecutionResults(headerHash, header, body) | ||
| } | ||
|
|
||
| func (sp *shardProcessor) AddExecutionResultsOnHeader(shardHeader data.HeaderHandler) error { |
There was a problem hiding this comment.
missing comments on exported methods
| for name, component := range subcomponents { | ||
| if err := setField(sp, name, component); err != nil { | ||
| if err2 := setField(sp.baseProcessor, name, component); err2 != nil { | ||
| return nil, err |
There was a problem hiding this comment.
is it intended here err or should it be err2? (perhaps rename err2 to errSetBaseProcessor)
There was a problem hiding this comment.
removed it altogether, it was not really necessary
| return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromShards shardInfo.HeaderHash = %s", | ||
| process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash)) |
There was a problem hiding this comment.
not sure we should add the name of the func inside the error.. maybe this could become somthing like
| return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromShards shardInfo.HeaderHash = %s", | |
| process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash)) | |
| return nil, fmt.Errorf("%w for shard info with hash = %s", | |
| process.ErrMissingHeader, hex.EncodeToString(shardInfo.HeaderHash)) |
similar for all
| return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromMeta metaBlockHash = %s", | ||
| process.ErrMissingHeader, hex.EncodeToString(metaBlockHash)) |
There was a problem hiding this comment.
same here:
| return nil, fmt.Errorf("%w : getAllMiniBlockDstMeFromMeta metaBlockHash = %s", | |
| process.ErrMissingHeader, hex.EncodeToString(metaBlockHash)) | |
| return nil, fmt.Errorf("%w for metaBlockHash %s", | |
| process.ErrMissingHeader, hex.EncodeToString(metaBlockHash)) |
| // but add them into pendingMiniBlocksAndHashes | ||
| if lastMBIndex != len(mbsSlice) { | ||
| pendingMiniBlocksAndHashes = miniBlocksAndHashes[lastMBIndex:] | ||
| if lastMBIndex+1 < len(mbsSlice) { |
There was a problem hiding this comment.
| if lastMBIndex+1 < len(mbsSlice) { | |
| if lastMBIndex < len(mbsSlice) - 1 { |
| }, | ||
| } | ||
| } | ||
| //body := &block.Body{} |
| type gracePeriodErrStub struct{} | ||
|
|
||
| func (gracePeriodErrStub) GetGracePeriodForEpoch(_ uint32) (uint32, error) { | ||
| return 0, errors.New("epochChangeGracePeriodHandler forced error") | ||
| } | ||
|
|
||
| func (gracePeriodErrStub) IsInterfaceNil() bool { return false } |
There was a problem hiding this comment.
extract it into a new file as a regular mock + comments on exported
| func TestShardProcessor_CheckEpochCorrectnessShouldErrorWhenIsHeaderOfInvalidEpoch(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| // isHeaderOfInvalidEpoch := header.GetEpoch() > sp.epochStartTrigger.MetaEpoch() |
| }, | ||
| } | ||
|
|
||
| //make epochChangeConfirmed true (sp.epochStartTrigger.EpochStartRound() <= sp.epochStartTrigger.EpochFinalityAttestingRound()) |
| func TestShardProcessor_CheckEpochCorrectnessShouldErrorWhenIsNotEpochStartButShouldBe(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| //isNotEpochStartButShouldBe := header.GetEpoch() != currentBlockHeader.GetEpoch() && !header.IsStartOfEpochBlock() |
Reasoning behind the pull request
Increase cover of shardProcessor and txCoordinator
Proposed changes
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?